<template>
	<view class="container">
		<view class="inner">
			<view class="share-list">
				<view class="share-item" v-for="(item,index) in shareList" :key="index">
					<image v-if="item.headPic" class="share-img" :src="item.headPic"></image>
					<image v-else class="share-img" src="@/static/new/user/default-head.png"></image>
					<view class="desc">
						<view class="share-name-state">
							<text>{{ item.nickName || interString(item.phone) || '--' }}</text>
							<view class="state" :class="{ 'is-success': item.isSuccess === 1 }"></view>
						</view>
						<text class="share-time">分享时间：{{ item.createdAt }}</text>
					</view>
				</view>
			</view>
			<gzListNull :list="shareList"></gzListNull>
		</view>
	</view>
</template>

<script setup>
	import { onLoad } from '@dcloudio/uni-app'
	import { ref } from 'vue'
	import { $getFansShareList } from '@/http/apiManager.js'
	
	onLoad(({ activityId }) => {
		getShareList(activityId)
	})
	
	// 分享列表
	const shareList = ref([])
	
	const interString = (s) => {
		if (!s) {
			return '*************'
		} else {
			return s.slice(0, 3) + '******' + s.slice(-3)
		}
	}
	
	
	
	
	// 请求分享记录
	async function getShareList(activityId){
		uni.showLoading({ title: '加载中...' })
		const { bizData } = await $getFansShareList(activityId)
		uni.hideLoading()
		shareList.value = bizData
	}
	
</script>

<style lang="less" scoped>
	.container{
		background-color: #F7F8FC;
		width: 100%;
		min-height: 100vh;
		.inner{
			padding: 40rpx 32rpx;
			.share-list{
				display: flex;
				flex-wrap: wrap;
				gap: 40rpx;
				.share-item{
					width: 100%;
					background-color: #fff;
					border-radius: 20rpx;
					display: flex;
					gap: 24rpx;
					padding: 24rpx;
					box-sizing: border-box;

					.share-img{
						width: 120rpx;
						height: 120rpx;
						border-radius: 18rpx;
					}
					
					.desc{
						display: flex;
						flex-direction: column;
						justify-content: space-around;
						.share-name-state{
							font-weight: 500;
							display: flex;
							gap: 24rpx;
							align-items: center;
							
							.state{
								width: 108rpx;
								height: 42rpx;
								background-size: 100% 100%;
								background-position: left top;
								background-repeat: no-repeat;
								background-image: url('https://jdyd-marketing-public.oss-cn-hangzhou.aliyuncs.com/yx/205e93c4-9788-43d3-986b-129c91aa8369.png');
								&.is-success{
									background-image: url('https://jdyd-marketing-public.oss-cn-hangzhou.aliyuncs.com/yx/04204e05-ab19-4509-a805-e697ab42b1a4.png');
								}
							}
						}
						.share-time{
							font-size: 28rpx;
							color: #999999;
						}
					}
				}
			}
		}
	}
</style>